home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Utilities / Miscellaneous / CopyPaste 3.3.4 / CopyPaste Tools Sourcecode / Remove Spaces / Remove Space.p next >
Encoding:
Text File  |  1997-06-06  |  1.7 KB  |  77 lines  |  [TEXT/CWIE]

  1. {•This sourcecode is an example for creating a FKey coderesource with•}
  2. {•Metrowerks Pascal. It is copyrighted by Peter Hoerster and released•}
  3. {•for free use in any Shareware or Freeware product as a way to thank all•}
  4. {•programmers who share code snippets. You may put this sources on any•}
  5. {•CD ROM or any Archive Server but you may not sell it. •}
  6.  
  7. {• For comments please write to <hoerster@muenster.de>•}
  8.  
  9. unit onespace;
  10.  
  11. interface
  12.  
  13.     uses
  14.         Types, OSUtils, GestaltEqu, Script, notification, Resources, Events,
  15.          PascalA4, QuickDraw, ToolUtils, Memory, LowMem, Scrap;
  16.  
  17.  
  18.  
  19. {$MAIN}
  20.                         
  21.     procedure main;        
  22.  
  23. implementation
  24.  
  25.  
  26.     
  27.     procedure dopaste;
  28.     const
  29.         pastecode=2422;
  30.     var 
  31.         qel: EvQelPtr;
  32.     begin
  33.             if ppostevent(3, pastecode, qel) = noerr then
  34.             qel^.evtqmodifiers := cmdkey;
  35.     end;
  36.  
  37.  
  38.  
  39.     procedure main;
  40.         const
  41.             step = 1000;
  42.         var
  43.             oldA4: LongInt;
  44.             myerr: oserr;
  45.             myclipsize, templongint: longint;
  46.             myclipHandle: handle;
  47.             substhandle: Handle;
  48.             i: integer;
  49.             subst: str15;
  50.     begin
  51.         oldA4 := SetCurrentA4;
  52.         myclipsize := GetScrap(nil, 'TEXT', templongint);
  53.         mycliphandle := Tempnewhandle(myclipsize,myerr);
  54.         if myerr=noerr then 
  55.             begin
  56.                 myclipsize := GetScraP(myclipHandle, 'TEXT', templongint);
  57.                 if myclipsize > 0 then
  58.                     begin
  59.                         
  60.                         subst := '  ';
  61.                         substhandle := newhandle(1);
  62.                         blockmove(@subst[1], substhandle^, 1);
  63.                         repeat
  64.                             i := ReplaceText(mycliphandle, substhandle, subst);
  65.                         until i = 0;
  66.                         myerr := ZeroScrap;
  67.                         myclipsize:=gethandlesize(mycliphandle);
  68.                         Temphlock(mycliphandle,myerr);
  69.                         myerr := putscrap(myclipsize, 'TEXT', myclipHandle^);
  70.                         Temphunlock(myCliphandle,myerr);
  71.                         dopaste;
  72.                     end;
  73.             end;
  74.         TempDisposeHandle(myCliphandle,myerr);
  75.         oldA4 := SetA4(oldA4);
  76.     end;
  77. end.